package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum MessageTypeEnum {
    ST("settlement_tally", "接收核销与退款的消息"),
    STF("settlement_tally_flow", "接收流水的消息"),
    STSO("settlement_tally_sub_order", "接收子订单的消息"),
    PAY("pay_tally", "订单支付消息"),
    CHANNEL_REPORT("channel_report", "广告渠道上报消息"),
    ORDER_SC("order_service_sc_tally", "订单服务成功消息");
    private String code;
    private String desc;


    public static String getDesc(String code) {
        Optional<MessageTypeEnum> found = Arrays.stream(MessageTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
